﻿
@{
    var action = Url.Action("Add", "BookInventory", new { Area = BookInventory.ModuleDefiniation.MODULE_NAME });
}

@section Header{
    <link rel="stylesheet" href="@Url.Action("GetModuleCSS", "System", new { moduleName = BookInventory.ModuleDefiniation.MODULE_NAME, fileName = "Content/module.css" })" />

    <style type="text/css">
        .out {
            background: #ef5a92;
            padding: 5px;
            border-radius: 3px;
            color: white;
        }

        .in {
            background: #5cbedf;
            padding: 5px;
            border-radius: 3px;
            color: white;
        }
    </style>
}

<h1>Books</h1>

<div><button type="button" class="btn btn-primary marginBottom1rem" onclick="window.location = '@action'">+ Add</button></div>

<div>
    <table class="table">
        <thead>
            <tr>
                <th>BookId</th>
                <th>Book Name</th>
                <th>ISBN</th>
                <th>Date Issued</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody>
            @if (Model != null && Model.Count > 0)
            {
                foreach (var item in Model)
                {
                    <tr>
                        <td>@item.BookId</td>
                        <td>@item.BookName</td>
                        <td>@item.ISBN</td>
                        <td>@item.DateIssued.ToString("yyyy-MM-dd")</td>
                        <td><span class="@(item.Status?"out":"in")">@(item.Status?"Out":"In")</span></td>
                    </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="4">No Records.</td>
                </tr>
            }
        </tbody>

    </table>
</div>
